<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="txt1">


<script type="text/javascript">
    var txt1 = document.getElementById('txt1');
    txt1.onkeydown = function (ev) {

        var oEvent = ev||event;
        if(oEvent.keyCode<48||oEvent.keyCode>57){
            return false;
        }

    }

</script>
</body>
</html>